package com.sfdk.graphics.ui.parts
{
import com.sfdk.graphics.core.MovieClipEx;

import flash.events.MouseEvent;

public class CheckBox extends MovieClipEx
	{
		private var checked_ : Boolean = false;
		
		public function CheckBox()
		{
			super();
			stop();
			addEventListener(MouseEvent.CLICK, changeState, false, 0, true);
		}
		
		private function changeState(e : MouseEvent) : void
		{
			checked_ = !checked_;
			updateView();
		}
		
		public function isChecked() : Boolean
		{
			return checked_;
		}
		
		public function setChecked(value : Boolean) : void
		{
			checked_ = value;
			// On met à jour la vue
			updateView();
		}
		
		private function updateView() : void
		{
			if (checked_)
				gotoAndStop(2);
			else
				gotoAndStop(1);
		}
	}
}